package cmich.cps.svn.utility;

import java.io.File;
import java.io.UnsupportedEncodingException;
import java.net.URLDecoder;
import java.util.logging.Level;

import cmich.cps.svn.utility.gui.GUIFrame;
import cmich.cps.svn.utility.gui.Prompts;

/**
 * The Class Main.
 *
 * @author Jonathan Kissinger <kissi1j@cmich.edu>
 */
public class Main {

	/**
	 * The main method.
	 *
	 * @param args the arguments
	 */
	public static void main(String[] args) {
		MyLogger.setup(Level.FINE, Level.FINEST, getDir());
		GUIFrame gui = GUIFrame.getInstance();
		Settings settings = Settings.getInstance();
		Prompts prompts = Prompts.getInstance();
		UtilitySystem system = UtilitySystem.getInstance();
		prompts.init();
		settings.init(getDir());
		system.init();
		settings.startup();
		system.startup();
		gui.updateButtons();
		gui.addFunctionality();
	}

	private static File getDir() {
		File dir = null;
		try {
			String location = Main.class.getProtectionDomain().getCodeSource().getLocation().getPath();
			String decodedLocation = URLDecoder.decode(location, "UTF-8");
			dir = new File(decodedLocation).getParentFile();
		} catch (UnsupportedEncodingException e) {
			e.printStackTrace();
		}
		return dir;
	}

}
